LetsDefend - PowerShell Keylogger

Created: 28/12/2025 18:13 Last Updated: 29/12/2025 10:56


Scenario

You are a malware analyst investigating a suspected PowerShell malware sample. The malware is designed to establish a connection with a remote server, execute various commands, and potentially exfiltrate data. Your goal is to analyze the malware’s functionality and determine its capabilities.


Start Investigation

8bf089b93e98b249ee4cbc8f30d00fd3.png d42ff808faa40f4e183e28b5cfcfa914.png

We have a single PowerShell file in this challenge. As the challenge name implies, we're dealing with a keylogger written in PowerShell. After opening it with VS Code, I can see parameter declarations at the top of the script along with C# code that will be executed via Add-Type.

Let's explore what each function does before answering the challenge questions.

This malware contains 9 main functions and a custom C# class. Let's understand each component: - Establish-Connection : This function is the core of this script, which is constantly run inside while loop and keep calling every 60 seconds after fails. it responsible for other function calling and establish connection back to the threat actor via SOCKS5 proxy to Tor hidden service and it handles command sending from the threat actor to each function defined in this script like a C2 including upload and download files from victim host as well 79093236239386cfde776299196dbe3b.png 0a6601fc5390f251c7417f28ef419b91.png

Now lets start answering the question and finish this challenge before wrap it up in summary

What is the proxy port used by the script?

38039a77099d131035d38f69c6aa4784.png

As this keylogger also have C2 capability and it will connect back to the threat actor TOR service, and the proxy port that was used is 9050 with the IP address of "37.143.129.165"

9050

What function-method is used for starting keylogging?

Start-Keylogger

What is the name of the file used by the script to store the keylog data?

keylog.txt

What command is used by the script to achieve persistence?

47e91fe411bfe98ef848c642ec15e685.png

The script does not yet implement any persistence mechanism yet but as we can see that it is intended to have one from the Establish-Connection function

persist

What is the command used by the script to upload data?

upload:

What is the regex used by the script to filter IP addresses?

^(127\.|169\.254\.)

What is the DLL imported by the script to call keylogging APIs?

9995d98a4ec81b7ba8ad083e6e0eb840.png

In Start-Keylogger function, 4 functions used for keylogging are imported from user32.dll

user32.dll

How many seconds does the script wait before re-establishing a connection?

60

Summary

In this challenge, we conducted script-based analysis on the PowerShell-based RAT demonstrates sophisticated attacker techniques including Tor-based anonymization, fileless execution, and keylogger functionality.

https://app.letsdefend.io/my-rewards/detail/af38186a2b204a378fd572aa8405185c